const router = require("koa-router")();
const { findNoteListById } = require("../controllers/index.js");
const jwt = require("../utils/jwt.js");


router.get("/findNoteListById",jwt.verify(), async (ctx) => {
  //获取前端传递的 id,去数据库中以该id字段 读取数据，返回给前端
  //console.log(ctx.request.query)
    const { id } = ctx.request.query;
  // console.log(res)
  try {
    const res = await findNoteListById(id);
    //console.log(res);
      ctx.body = {
        code: "8000",
        data: res,
        msg: "查询成功",
      };
    
  } catch (error) {
    ctx.body = {
      code: "8005",
      data: error, 
      msg: "服务器异常"
    };
  }
});

module.exports = router;
